<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增推送任务')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-record-add">

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">执行日期：</label>
                <div class="col-sm-8">
                    <input name="execDate" id="execDate" class="form-control" readonly type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">执行时间：</label>
                <div class="col-sm-8" id="execTime">
                    <div class="col-sm-6">
                        <input name="execStartTime" id="execStartTime" class="form-control" readonly type="text" required>
                    </div>
                    <div class="col-sm-6">
                        <input name="execEndTime" id="execEndTime" class="form-control" readonly type="text" required>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">机构信息：</label>
                <div class="col-sm-8">
                    <select name="dataId" class="form-control" >
                        <option  th:each="item:${channelInfoList}" th:text="${item.name}" th:value="${item.value}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">数据时间范围：</label>
                <div class="col-sm-8" id="datetime">
                    <div class="col-sm-6">
                        <input name="starttime" id="starttime" class="form-control" readonly type="text" required>
                    </div>
                    <div class="col-sm-6">
                        <input name="endtime" id="endtime" class="form-control" readonly type="text" required>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label"></label>
                <div class="col-sm-8" >
                    <span class="help-block m-b-none" style="margin-top: 20px">
                        该范围内的数据量：<elem id="totalNumber" style="color: red">0</elem>。
                        <button type="button" class="btn-primary" onclick="queryCount()"> 查询</button>
                    </span>

                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">推送时间间隔（秒）：</label>
                <div class="col-sm-8">
                    <select name="pushSpace" class="form-control" >
                        <option value="10">10</option>
                        <option value="20">20</option>
                        <option value="30">30</option>
                        <option value="40">40</option>
                        <option value="50">50</option>
                        <option value="60">60</option>
                    </select>
                </div>
            </div>

            <div class="form-group" >
                <label class="col-sm-3 control-label" >芝麻分:</label>
                <div class="col-sm-8">
                    <label class="check-box" th:each="item:${dataMapList}">
                        <input type="checkbox" lay-skin="primary" name="filterZhima" th:value="${item.value}" th:text="${item.name}" >
                    </label>
                </div>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "form/record"
        $("#form-record-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-record-add').serialize());
            }
        }

        function queryCount(){
            var starttime = $("#starttime").val()
            var endtime = $("#endtime").val()

            if ($.common.isEmpty(starttime) || $.common.isEmpty(endtime)) {
                $.modal.msg("时间不能为空");
                return;
            }

            $.ajax({
                type: "post",
                url: ctx + 'member/extInfo/count',
                data: {
                    "starttime": starttime,
                    "endtime": endtime
                },
                success: function(result) {
                    if (result.code == 0) {
                        $("#totalNumber").text(result.data)
                    }
                }
            });
        }

        layui.use('laydate', function(){
            var laydate = layui.laydate;


            laydate.render({
                elem: '#execDate',
                type: 'date'
            });

            laydate.render({
                elem: '#execTime',
                type: 'time'
                ,range: ['#execStartTime', '#execEndTime']
            });

            laydate.render({
                elem: '#datetime',
                type: 'datetime'
                ,min: -7
                ,max:7
                ,range: ['#starttime', '#endtime']
            });
        });
    </script>
</body>
</html>